package com.outsider.view;

import com.outsider.dictlistbea.R;

import android.annotation.SuppressLint;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.ImageButton;

public class CollectionButton extends ImageButton {
	public static int SAVE = 1;
	public static int UNSAVE = 0;
	
	private int rating = UNSAVE;
	private MyOnClickListener myOnClickListener;

	public CollectionButton(Context context) {
		super(context);
	}

	public CollectionButton(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
	}

	public CollectionButton(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public int getRating() {
		return rating;
	}

	public void setRating(int rating) {
		this.rating = rating;
		if(rating == SAVE){
			this.setBackgroundResource(R.drawable.save);
		}else if(rating == UNSAVE){
			this.setBackgroundResource(R.drawable.unsave);
		}
	}

	
	@SuppressLint("ClickableViewAccessibility")
	@Override
	public boolean onTouchEvent(MotionEvent event) {
		// TODO Auto-generated method stub
		if(myOnClickListener!=null) return myOnClickListener.onClick(event);
		return false;
	}

	public MyOnClickListener getMyOnClickListener() {
		return myOnClickListener;
	}

	public void setMyOnClickListener(MyOnClickListener myOnClickListener) {
		this.myOnClickListener = myOnClickListener;
	}


	
	


}
